********************************************************************************
*																			   *
*						Sir! I'd Rather Go to School Sir!					   *
*																			   *
*								 Mahdi Majbouri								   *
*																			   *
*									Figure A1								   *
*																			   *
*									6-6-2023								   *
*																			   *
********************************************************************************


********************************************************************************
**  Test for discontinuity in the number of observations
********************************************************************************

use "census11-all.dta", clear

keep if fage>=fage18 & fage18>=threshold - 9 & fage18<=threshold + 10 & ///
		father_ed !=. & mom_ed != . & fage !=. & mage !=.

keep if relate == 3 & son == 1 & sons == 1 & urban == 2

gen number = 1
collapse (mean) t tfa fasq facb tfasq tfacb fage18 (sum) number, by(fa)

twoway ///
(scatter number fage18, mcolor(gs3)) ///
(lfitci number fage18 if t==1, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lfitci number fage18 if t==0, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) ///
	xtitle("Age of the Sole Son's Father") ytitle("Number of Observations") ///
	title("Linear fit")  note("") saving("numberl.eps", replace)

twoway ///
(scatter number fage18, mcolor(gs3)) ///
(qfitci number fage18 if t==1, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(qfitci number fage18 if t==0, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) ///
	xtitle("Age of the Sole Son's Father") ytitle("Number of Observations") ///
	title("Quadratic fit")  note("") saving("numberq.eps", ///
	replace)

twoway ///
(scatter number fage18, mcolor(gs3)) ///
(lpolyci number fage18 if t==1, n(100) fcolor(none) ciplot(rline) clcolor(gs5)) ///
(lpolyci number fage18 if t==0, n(100) fcolor(none) ciplot(rline) clcolor(gs5)), ///
	xline(58)  legend(off) graphregion(color(white)) yscale(range(0 1)) ///
	xtitle("Age of the Sole Son's Father") ytitle("Number of Observations") ///
	title("Polynomial fit")  note("") saving("numberp.eps", ///
	replace)


graph combine "numberl.eps" "numberq.eps" ///
"numberp.eps", ycommon ///
graphregion(color(white)) rows(1) cols(3) xsize(12) ysize(4) iscale(*1.5)

graph export "FigureA1.pdf", replace

	
********************************************************************************
*********************************  THE END *************************************
********************************************************************************
